home *** CD-ROM | disk | FTP | other *** search
/ Champak 66 / Vol 66.iso / games / doodle_d.swf / scripts / frame_4 / DoAction_8.as < prev    next >
Text File  |  2013-04-24  |  6KB  |  154 lines

  1. function laserFire()
  2. {
  3.    laserTimer++;
  4.    if(laserTimer == laserSpeed)
  5.    {
  6.       switch(laserType)
  7.       {
  8.          case "standard":
  9.             depth = _root.lasers.getNextHighestDepth();
  10.             _root.lasers.attachMovie("laser","laser" + depth,depth);
  11.             curLas = eval("_root.lasers.laser" + depth);
  12.             curLas._x = ship._x;
  13.             curLas._y = ship._y;
  14.             curLas.dir = dir;
  15.             laserTimer = 0;
  16.             curLas._rotation = curLas.dir;
  17.             curLas.degrees = curLas.dir;
  18.             curLas.degrees -= 90;
  19.             curLas.radians = degrees * rad;
  20.             curLas.thrustDX = (speed / 2 + laserThrust) * cos(curLas.radians);
  21.             curLas.thrustDY = (speed / 2 + laserThrust) * sin(curLas.radians);
  22.             curLas.dx = curLas.thrustDX;
  23.             curLas.dy = curLas.thrustDY;
  24.             curLas._x += curLas.dx * 2;
  25.             curLas._y += curLas.dy * 2;
  26.             break;
  27.          case "burst":
  28.             depth = _root.lasers.getNextHighestDepth();
  29.             _root.lasers.attachMovie("laser","laser" + depth,depth);
  30.             curLas = eval("_root.lasers.laser" + depth);
  31.             curLas._x = ship._x;
  32.             curLas._y = ship._y;
  33.             curLas.dir = dir;
  34.             laserTimer = 0;
  35.             curLas._rotation = curLas.dir;
  36.             curLas.degrees = curLas.dir;
  37.             curLas.degrees -= 90;
  38.             curLas.radians = curLas.degrees * rad;
  39.             curLas.thrustDX = (speed / 2 + laserThrust) * cos(curLas.radians);
  40.             curLas.thrustDY = (speed / 2 + laserThrust) * sin(curLas.radians);
  41.             curLas.dx = curLas.thrustDX;
  42.             curLas.dy = curLas.thrustDY;
  43.             curLas._x += curLas.dx * 2;
  44.             curLas._y += curLas.dy * 2;
  45.             depth = _root.lasers.getNextHighestDepth();
  46.             _root.lasers.attachMovie("laser","laser" + depth,depth);
  47.             curLas = eval("_root.lasers.laser" + depth);
  48.             curLas._x = ship._x;
  49.             curLas._y = ship._y;
  50.             curLas.dir = dir + 7;
  51.             laserTimer = 0;
  52.             curLas._rotation = curLas.dir;
  53.             curLas.degrees = curLas.dir;
  54.             curLas.degrees -= 90;
  55.             curLas.radians = curLas.degrees * rad;
  56.             curLas.thrustDX = (speed / 2 + laserThrust) * cos(curLas.radians);
  57.             curLas.thrustDY = (speed / 2 + laserThrust) * sin(curLas.radians);
  58.             curLas.dx = curLas.thrustDX;
  59.             curLas.dy = curLas.thrustDY;
  60.             curLas._x += curLas.dx * 2;
  61.             curLas._y += curLas.dy * 2;
  62.             depth = _root.lasers.getNextHighestDepth();
  63.             _root.lasers.attachMovie("laser","laser" + depth,depth);
  64.             curLas = eval("_root.lasers.laser" + depth);
  65.             curLas._x = ship._x;
  66.             curLas._y = ship._y;
  67.             curLas.dir = dir - 7;
  68.             laserTimer = 0;
  69.             curLas._rotation = curLas.dir;
  70.             curLas.degrees = curLas.dir;
  71.             curLas.degrees -= 90;
  72.             curLas.radians = curLas.degrees * rad;
  73.             curLas.thrustDX = (speed / 2 + laserThrust) * cos(curLas.radians);
  74.             curLas.thrustDY = (speed / 2 + laserThrust) * sin(curLas.radians);
  75.             curLas.dx = curLas.thrustDX;
  76.             curLas.dy = curLas.thrustDY;
  77.             curLas._x += curLas.dx * 2;
  78.             curLas._y += curLas.dy * 2;
  79.       }
  80.       if(rightLaser)
  81.       {
  82.          rightDegrees = ship._rotation - 45;
  83.          rightRadians = rightDegrees * rad;
  84.          depth = _root.lasers.getNextHighestDepth();
  85.          _root.lasers.attachMovie("laser","laser" + depth,depth);
  86.          curLas = eval("_root.lasers.laser" + depth);
  87.          rPx = 15 * cos(rightRadians);
  88.          rPy = 10 * sin(rightRadians);
  89.          curLas._x = ship._x + rPx;
  90.          curLas._y = ship._y + rPy;
  91.          curLas.dir = dir;
  92.          laserTimer = 0;
  93.          curLas._rotation = curLas.dir;
  94.          curLas.degrees = curLas.dir;
  95.          curLas.degrees -= 90;
  96.          curLas.radians = curLas.degrees * rad;
  97.          curLas.thrustDX = (speed / 2 + laserThrust) * cos(curLas.radians);
  98.          curLas.thrustDY = (speed / 2 + laserThrust) * sin(curLas.radians);
  99.          curLas.dx = curLas.thrustDX;
  100.          curLas.dy = curLas.thrustDY;
  101.          curLas._x += curLas.dx * 2;
  102.          curLas._y += curLas.dy * 2;
  103.       }
  104.       if(leftLaser)
  105.       {
  106.          leftDegrees = ship._rotation - 135;
  107.          leftRadians = leftDegrees * rad;
  108.          depth = _root.lasers.getNextHighestDepth();
  109.          _root.lasers.attachMovie("laser","laser" + depth,depth);
  110.          curLas = eval("_root.lasers.laser" + depth);
  111.          lPx = 15 * cos(leftRadians);
  112.          lPy = 10 * sin(leftRadians);
  113.          curLas._x = ship._x + lPx;
  114.          curLas._y = ship._y + lPy;
  115.          curLas.dir = dir;
  116.          laserTimer = 0;
  117.          curLas._rotation = curLas.dir;
  118.          curLas.degrees = curLas.dir;
  119.          curLas.degrees -= 90;
  120.          curLas.radians = curLas.degrees * rad;
  121.          curLas.thrustDX = (speed / 2 + laserThrust) * cos(curLas.radians);
  122.          curLas.thrustDY = (speed / 2 + laserThrust) * sin(curLas.radians);
  123.          curLas.dx = curLas.thrustDX;
  124.          curLas.dy = curLas.thrustDY;
  125.          curLas._x += curLas.dx * 2;
  126.          curLas._y += curLas.dy * 2;
  127.       }
  128.       if(backLaser)
  129.       {
  130.          backDegrees = ship._rotation + 90;
  131.          backRadians = backDegrees * rad;
  132.          depth = _root.lasers.getNextHighestDepth();
  133.          _root.lasers.attachMovie("laser","laser" + depth,depth);
  134.          curLas = eval("_root.lasers.laser" + depth);
  135.          bPx = 15 * cos(backRadians);
  136.          bPy = 10 * sin(backRadians);
  137.          curLas._x = ship._x + bPx;
  138.          curLas._y = ship._y + bPy;
  139.          curLas.dir = dir + 180;
  140.          laserTimer = 0;
  141.          curLas._rotation = curLas.dir;
  142.          curLas.degrees = curLas.dir;
  143.          curLas.degrees -= 90;
  144.          curLas.radians = curLas.degrees * rad;
  145.          curLas.thrustDX = (speed / 2 + laserThrust) * cos(curLas.radians);
  146.          curLas.thrustDY = (speed / 2 + laserThrust) * sin(curLas.radians);
  147.          curLas.dx = curLas.thrustDX;
  148.          curLas.dy = curLas.thrustDY;
  149.          curLas._x += curLas.dx * 2;
  150.          curLas._y += curLas.dy * 2;
  151.       }
  152.    }
  153. }
  154.